package com.web.servlet;

import com.web.entity.TestBiao;
import com.web.service.TestBiaoService;
import com.web.serviceimpl.TestBiaoServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 获取申请状态的servlet
 * @author 12270
 */
@WebServlet("/ats")
public class ApplyTestServlet extends HttpServlet{
    
    TestBiaoService tbs = new TestBiaoServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        //1. 获取请求参数
        HttpSession session = req.getSession();
        int testid;
        if(req.getParameter("testid")==null){
            testid = (int)session.getAttribute("testid");
        }else{
            testid = Integer.parseInt(req.getParameter("testid"));
        }
        
    
        //2. 执行业务逻辑
        TestBiao tb = tbs.searchStatus(testid);
        int x = tb.getIstestfinish();
        session.setAttribute("teststatus", tb);      
        System.out.println(x);
        resp.sendRedirect("/J03_T12_P02/test/test.jsp");
    }
}
